package com.common.pojo.detail;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class RecordGroup {
    private Date date;
    private List<Record> records;
    private double incomeTotal;
    private double expenseTotal;

    public RecordGroup(Date date) {
        this.date = date;
        this.records = new ArrayList<>();
        this.incomeTotal = 0;
        this.expenseTotal = 0;
    }

    public void addRecord(Record record) {
        records.add(record);
        if (record.getType() == Record.Type.INCOME) {
            incomeTotal += record.getAmount();
        } else {
            expenseTotal += record.getAmount();
        }
    }

    // Getters
    public Date getDate() { return date; }
    public List<Record> getRecords() { return records; }
    public double getIncomeTotal() { return incomeTotal; }
    public double getExpenseTotal() { return expenseTotal; }
    public double getDayBalance() { return incomeTotal - expenseTotal; }
}
